from sklearn.datasets import load_wine
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import  train_test_split

import numpy as np

wine_dataset=load_wine()

X_train,X_test,Y_train,Y_test=train_test_split(wine_dataset['data'], wine_dataset['target'], test_size=0.2, random_state=0)

# ID3
tree_model=DecisionTreeClassifier(criterion="entropy")

tree_model.fit(X_train, Y_train)

score = tree_model.score(X_test, Y_test)

print(score)

X_wine_test=np.array([[11.8,4.39,2.39,29,82,2.86,3.53,0.21,2.85,2.8,.75,3.78,490]])

predict_result=tree_model.predict(X_wine_test)

print(predict_result)

print("分类结果：{}".format(wine_dataset['target_names'][predict_result]))

